const router = require("@koa/router");
const Router = new router();
const jwt = require("../utils/jwt");
const { findShop } = require("../controllers");

Router.get("/findShop", async (ctx, next) => {
  // 检验token合理再去数据库中查找数据返回给前端
  // const { shopId } = ctx.request.query;
  // console.log(ctx.request);
  try {
    const res = await findShop();
    console.log(res);
    if (res.length) {
      ctx.body = {
        code: "800",
        data: res,
        msg: "查询成功",
      };
    } else {
      ctx.body = {
        code: "800",
        data: res,
        msg: "当前分类下没有数据",
      };
    }
  } catch (error) {
    ctx.body = {
      code: "805",
      data: error,
      msg: "服务器异常",
    };
  }
});

module.exports = Router;
